/**
 * Created by bing on 2019/3/7.
 */
package com.wxb.hello.thread;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * describe:
 *
 * @author : wxbing000@gmail.com
 * @version : v1.0
 * @date : 2019-03-07 11:24
 */
public class ThreadExecutorDemo {

	public static void main(String[] args) {
		ExecutorService fixedThreadPool = new ThreadPoolExecutor(2, 2, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>());
		for (int i = 0; i < 10; i++) {
			final int index = i;
			fixedThreadPool.execute(() -> {
				try {
					System.out.println(index);
					Thread.sleep(2000);
				} catch (InterruptedException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			});
		}
	}

}
